package com.qc.vod.controller;

import com.qc.commonutils.result.R;
import com.qc.vod.service.VodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Api("视频上传")
@RestController
@CrossOrigin //跨域
@RequestMapping("/eduvod")
public class VodController {

    @Autowired
    private VodService vodService;

    @ApiOperation("视频上传到阿里云")
    @PostMapping("uploadAliyun")
    public R uploadAliyun(MultipartFile file){
        String videoId = vodService.uploadVod(file);
        return R.ok().data("videoId",videoId);
    }

    @ApiOperation("删除视频")
    @DeleteMapping("{videoId}")
    public R removeVideo(@ApiParam(name = "videoId", value = "云端视频id", required
            = true)@PathVariable String videoId){
        vodService.removeVideo(videoId);
        return R.ok().message("视频删除成功");
    }



}
